package com.android.signhelper.ui;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.android.signhelper.R;
import com.android.signhelper.bean.Student;

public class AddActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);
        final EditText etUserName = findViewById(R.id.et_userName);
        final EditText etPassword = findViewById(R.id.et_password);
        findViewById(R.id.bt_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String userName=etUserName.getText().toString();
                String password=etPassword.getText().toString();
                if (!TextUtils.isEmpty(userName)&&!TextUtils.isEmpty(password)) {
                    Student student=new Student(userName,password);
                    Intent intent = new Intent(AddActivity.this, MainActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    intent.putExtra("student", student);
                    startActivity(intent);
                }
            }
        });


        
    }
}
